namespace LetLord.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class addedSavedPropertyModel : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.ResidentialProperty", "Tenant_UserId", "dbo.Tenant");
            DropIndex("dbo.ResidentialProperty", new[] { "Tenant_UserId" });
            CreateTable(
                "dbo.SavedProperty",
                c => new
                    {
                        ResidentialPropertyId = c.Int(nullable: false),
                        Tenant_UserId = c.Int(),
                    })
                .PrimaryKey(t => t.ResidentialPropertyId)
                .ForeignKey("dbo.ResidentialProperty", t => t.ResidentialPropertyId)
                .ForeignKey("dbo.Tenant", t => t.Tenant_UserId)
                .Index(t => t.ResidentialPropertyId)
                .Index(t => t.Tenant_UserId);
            
            DropColumn("dbo.ResidentialProperty", "Discriminator");
            DropColumn("dbo.ResidentialProperty", "Tenant_UserId");
        }
        
        public override void Down()
        {
            AddColumn("dbo.ResidentialProperty", "Tenant_UserId", c => c.Int());
            AddColumn("dbo.ResidentialProperty", "Discriminator", c => c.String(nullable: false, maxLength: 128));
            DropIndex("dbo.SavedProperty", new[] { "Tenant_UserId" });
            DropIndex("dbo.SavedProperty", new[] { "ResidentialPropertyId" });
            DropForeignKey("dbo.SavedProperty", "Tenant_UserId", "dbo.Tenant");
            DropForeignKey("dbo.SavedProperty", "ResidentialPropertyId", "dbo.ResidentialProperty");
            DropTable("dbo.SavedProperty");
            CreateIndex("dbo.ResidentialProperty", "Tenant_UserId");
            AddForeignKey("dbo.ResidentialProperty", "Tenant_UserId", "dbo.Tenant", "UserId");
        }
    }
}
